(function(angular) {
	"use strict";
	angular.module("fs.waf").controller("cls.paySwift.viewController", viewController);
	viewController.$inject = [ "$scope", "$q", "modalService", "layoutConfig", "validatorConfig", "authService", "paySwiftMonitorService" ];
	function viewController($scope, $q, modalService, layoutConfig, validatorConfig, authService, paySwiftMonitorService) {
		var ctrl = this, paySwiftInfo = $scope.$stateParams.params, settlement = {};
		ctrl.validatorConfig = validatorConfig;
		ctrl.init = function() {
			paySwiftMonitorService.initViewOptions().then(function(map) {
				return $q(function(resolved, rejected) {
					settlement.deliveryTypeOptions = map.deliveryTypeOptions;
					settlement.currencyOptions = map.currencyOptions;
					settlement.allPartyTypeOptions = map.partyTypeOptions;
					settlement.swiftCaseList = map.swiftCaseList;
					ctrl.settlement = settlement;
					resolved(settlement);
				});
			}).then(function(settlement) {
				authService.view(paySwiftInfo).then(function(response) {
					var paySwift = response.data || paySwiftInfo;
					ctrl.payParty_Config = paySwiftMonitorService.initPayPartyTabs(paySwift, settlement, layoutConfig);
					ctrl.layoutConfig = layoutConfig;
					ctrl.paySwift = paySwift;
				}, angular.noop);
			});
		};

		ctrl.swiftFileLink = function(paySwift, from) {
			modalService.openCustomDialogs({
				"title" : "title.popup.view.swiftfile",
				"dialogsModule" : "cls.paySwift.swiftFile",
				"params" : {
					"paySwift" : paySwift
				},
				"btnCallback" : {
					"ok" : function() {
					}
				}
			});
		};

	}
})(angular);